<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>看代码说输出</title>
</head>
<body>
    <script>
        function Foo(){
            getName = function(){
                console.log(0);
            }
            return this;
        }
        var getName = function(){
            console.log(1);
        }
        Foo.getName = function(){
            console.log(2);
        }
        function getName(){
            console.log(3);
        }
        Foo.prototype.getName = function(){
            console.log(4);
        }

        Foo.getName() // 2
        getName() // 1
        new Foo().getName() //4
        getName() // 0
        Foo().getName() //0


    </script>
</body>
</html>